package com.mdb.open.epay.feign.fallback;

import com.mdb.bc.api.data.ListResultEx;
import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.api.enums.ResultCode;
import com.mdb.open.epay.feign.OutreachClient;
import com.mdb.open.epay.feign.dto.*;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *
 * @author liuyi
 * @Date 2019-11-15
 */
@Slf4j
@Component
public class OutreachFallbackFactory implements FallbackFactory<OutreachClient> {
    @Override
    public OutreachClient create(Throwable throwable) {

        log.error("调用外联中心服务[cnt-outreach]发生异常", throwable);
        ResultEx result = ResultEx.makeResult(ResultCode.INVOKING_REMOTE_SERVICE, "调用外联中心服务服务发生异常");

        return new OutreachClient() {

            @Override
            public ResultEx requestCoreApi9951000(SMS_9951000 dto) {
                result.setRetMsg("OutreachFallback error info: requestCoreApi9951000-核心短信發送 error! Cause:{}" + throwable.getMessage());
                return ResultEx.fail();
            }

            @Override
            public ListResultEx<HST_0359907_Resp> requestCoreApi0359907(HST_0359907 dto) {
                result.setRetMsg("OutreachFallback error info: requestCoreApi0359907-节假日查询 error! Cause:{}" + throwable.getMessage());
                return ListResultEx.fail();
            }

            @Override
            public ResultEx<HST_0350201_Resp> requestCoreApi0350201(HST_0350201 dto) {
                result.setRetMsg("OutreachFallback error info: requestCoreApi0350201-查询客户信息 error! Cause:{}" + throwable.getMessage());
                return ResultEx.fail();
            }

            @Override
            public ResultEx requestCoreApi0350202(HST_0350202 dto) {
                result.setRetMsg("OutreachFallback error info: requestCoreApi0350202-客户账号查询 error! Cause:{}" + throwable.getMessage());
                return ResultEx.fail();
            }

            @Override
            public ResultEx<HST_9998889_Resp> requestCoreApi9998889(HST_9998889 dto) {
                result.setRetMsg("OutreachFallback error info: requestCoreApi9998889-沖正接口 error! Cause:{}" + throwable.getMessage());
                return ResultEx.fail();
            }

            @Override
            public ResultEx<HST_0351430_Resp> requestCoreApi0351430(HST_0351430 dto) {
                return null;
            }

            @Override
            public ResultEx<HST_0359902_Resp> requestCoreApi0359902(HST_0359902 dto) {
                return null;
            }
        };
    }
}
